
<?php

include 'db_connection.php';
include 'navigation.php';

$query = "select * from DEVICE";
//execute query
$QueryResult = @mysqli_query($DBConnect, $query) or die("<p>Unable to execute query.</p>");	

$num_attributes = mysqli_num_fields($QueryResult);
$attributes = mysqli_fetch_fields($QueryResult);

echo "<h1>Devices</h1>";

echo "<table border ='0'>";

  echo "<tr bgcolor='#64AAD0'>";
  foreach($attributes as $val){	
    echo "<td>".$val->name."</td>";	
  }
  echo "<td></td>";
  echo "</tr>";

while ($row = mysqli_fetch_row($QueryResult)) {
  echo "<tr>";
  for($i=0; $i<$num_attributes;$i++){
	
	echo "<td>".$row[$i]."</td>";	

	}

echo "<td><a href='test_series.php?dev_id=".$row[0]."'>[View existing test series]</a></td></tr>";

  echo "<tr>";

  for($i=0; $i<$num_attributes-1;$i++){
	echo "<td></td>";	
	}

  echo "<td></td><td><b>--or-- add a new test series:</b><br/><form action='test_series.php' method='POST'>
	<input type='hidden' name='dev_id' value=$row[0] />
	Description:<br/><textarea name='test_series_desc' rows='3' cols='50'>
	</textarea><br/>
	<input type='submit' name='submit' value='Add new test series' />

  </form></td></tr>";

  //echo "<td><a href='test_series.php?dev_id=".$row[0]."'>[Add a new test series]</a></td>";
  //echo "</tr>";

}

echo "</table>";

?>



<html>
<body>

</body>
</html>

